Repository navigation
Adds a setting to retry transient errors - #9
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The POST rejection-callback path bypasses the Retry-After delay and 10-second limit, allowing a premature retry, and the HTTP-date timing test can fail across a second boundary.
2 open issues
What changed in this PR
Adds opt-in transient-error retries to RestEasy’s HTTP request lifecycle, reducing the need for retry policies in authentication strategies.
Changes:
- Adds
retry_transient_errors, disabled by default, with method-aware handling of HTTP failures and network errors. - Introduces
Retry-Afterparsing, a default delay, and a maximum wait. - Documents the retry policy and adds coverage for retries, limits, and authentication fallback.
| File | Description |
|---|---|
spec/rest_easy/resource/http_spec.rb |
Tests transient retries, delays, method restrictions, and fallback behavior. |
README.md |
Documents the setting and retry lifecycle. |
lib/rest_easy/settings.rb |
Defines the disabled-by-default setting. |
lib/rest_easy.rb |
Implements transient-error handling and retry-delay parsing. |
CHANGELOG.md |
Records the new setting and its behavior. |
Review effort: Balanced
Every failed response went to the authentication's on_rejected, which decided whether to retry. That left retrying a 429 or 5xx to the auth strategy, so a consumer that wanted it had to put a retry policy inside its authentication class. With retry_transient_errors on, the retry loop handles transient errors itself and on_rejected only sees the other failures. A 429 means the server did not act on the request, so it is retried for any method. A 5xx can arrive after the server already acted, so it is retried only on GET, PUT and DELETE; on POST it goes to on_rejected, since retrying a creating POST could create twice. Timeouts and dropped connections (Faraday::TimeoutError and ConnectionFailed) are retried on the same terms as a 5xx. They have no response for on_rejected, so without the setting they are raised as before. Every retry waits for Retry-After, which a 503 commonly carries as well as a 429. It is read in base 10, so "010" is not octal, and as an HTTP date when it is not a number; without it the wait is 1 second. One asking for more than 10 seconds raises at once, as retrying before the server allows would only use up the retries on further 429s. It is off by default: a strategy whose on_rejected raises gets no retries today and would start retrying, and PUT and DELETE are only safe to repeat on APIs that implement them idempotently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ehannes
force-pushed
the
retry-transient-errors
branch
from
November 17, 2026 13:34
4bf9294 to
f6c4d8c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Every failed response went to the authentication's on_rejected, which decided whether to retry. That left retrying a 429 or 5xx to the auth strategy, so a consumer that wanted it had to put a retry policy inside its authentication class.
With retry_transient_errors on, the retry loop handles transient errors itself and on_rejected only sees the other failures. A 429 means the server did not act on the request, so it is retried for any method. A 5xx can arrive after the server already acted, so it is retried only on GET, PUT and DELETE; on POST it goes to on_rejected, since retrying a creating POST could create twice. Timeouts and dropped connections (Faraday::TimeoutError and ConnectionFailed) are retried on the same terms as a 5xx. They have no response for on_rejected, so without the setting they are raised as before.
Every retry waits for Retry-After, which a 503 commonly carries as well as a 429. It is read in base 10, so "010" is not octal, and as an HTTP date when it is not a number; without it the wait is 1 second. One asking for more than 10 seconds raises at once, as retrying before the server allows would only use up the retries on further 429s.
It is off by default: a strategy whose on_rejected raises gets no retries today and would start retrying, and PUT and DELETE are only safe to repeat on APIs that implement them idempotently.